package com.wzq.util;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wzq.dao.dto.Appointmentdto;
import com.wzq.dao.pojo.Appointment;

public class AppointmenTextract {
    // 获取上一年的 lqw 表达式
    public static LambdaQueryWrapper<Appointment> getOldLqw(LambdaQueryWrapper<Appointment> lqw, Appointmentdto appointmentdto, String key, Integer format) {
        lqw.clear();
        lqw.select(Appointment::getBegin_time,Appointment::getEnd_time);    //查询开始结束时间
        lqw.eq(Appointment::getIsover,0).eq(Appointment::getPass,1);
        lqw.eq(Appointment::getP_id, appointmentdto.getP_id()).eq(Appointment::getFormat, format);
        lqw.likeRight( Appointment::getBegin_time, Integer.parseInt( key.substring(0,4) ) -1 );
        lqw.likeRight( Appointment::getEnd_time, Integer.parseInt( key.substring(0,4) )  );
        return lqw;
    }

    public static LambdaQueryWrapper<Appointment> getNowLqw(Appointmentdto appointmentdto, String key, LambdaQueryWrapper<Appointment> lqw ,Integer... format) {
        lqw.clear();
        lqw.select(Appointment::getBegin_time,Appointment::getEnd_time,Appointment::getFormat);    //查询开始结束时间
        lqw.eq(Appointment::getIsover,0).eq(Appointment::getPass,1);
        lqw.eq(Appointment::getP_id, appointmentdto.getP_id()).in(Appointment::getFormat, format);
        lqw.likeRight( Appointment::getBegin_time,  key );
        return lqw;
    }

}
